<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui" 
	template="/template/template.xhtml">

  <ui:define name="center">
  <h1 class="title ui-widget-header ui-corner-all">${msg['admin.list.title']}</h1>
  <h:messages id="success" layout="table"/>
  <h:form id="editForm" action="bookEdit">
  <p:commandButton value="${msg['admin.list.addBook']}" action="#{bookBean.addBook}" />	<br/>
  <p:dataTable var="book" value="#{bookListBean.books}">
  <p:column>
  		<f:facet name="header">
  			ID
  		</f:facet>
  		<h:outputText value="#{book.id}" />
  	</p:column>
 	<p:column>
  		<f:facet name="header">
  			Image
  		</f:facet>
  		<h:graphicImage id="gi" alt="#{book.title}" value="/resources/img/cover#{book.id}" width="100" height="100" title="#{book.title}" ></h:graphicImage>
  	</p:column>
  	<p:column>
  		<f:facet name="header">
			${msg['admin.table.title']}
  		</f:facet>
  		<h:outputText value="#{book.title}" />
  	</p:column>
  	<p:column>
  		<f:facet name="header">
			Auteurs
  		</f:facet>
  	</p:column>
  	<p:column>
  		<f:facet name="header">
			${msg['admin.table.price']}
  		</f:facet>
  		<h:outputText value="#{book.price}" />
  	</p:column>
  	<p:column>
  		<f:facet name="header">	
			${msg['admin.table.category']}
  		</f:facet>
  		<h:outputText value="#{book.category.title}" />
  	</p:column>
  	<p:column>
	<f:facet name="header">
		Action
	</f:facet>
	 <h:commandLink class="edit" action="bookEdit">
		<f:setPropertyActionListener target="#{bookBean.book}" value="#{book}" />	  
		<h:outputText value="${msg['bouton.modifier']}" />
	 </h:commandLink>
	 <br/>
	 <h:commandLink class="delete" action="#{bookBean.delete(book)}">	  
		<h:outputText value="${msg['bouton.delete']}" />
	 </h:commandLink>
  	</p:column>
  </p:dataTable>
  </h:form>
  </ui:define>

</ui:composition>